//class BrowerManager
    
    export  class BrowerManager
    {
        constructor()
        {
            
            if (BrowerManager._instance != null) 
            {
                throw "BrowerManager 为单例";
            }
            return;
        }

        public get url(): string
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return null;
            }
            try 
            {
                return flash.external.ExternalInterface.call("Brower.getURL");
            }
            catch (e)
            {
            };
            return "";
        }

        public get baseUrl(): string
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return null;
            }
            var url=this.url;
            var index=url.indexOf("#");
            if (index > 0) 
            {
                return url.substr(0, (index - 1));
            }
            return url;
        }

        public asCallJsFun(arg1: string): Boolean
        {
            var jsFun: string;

            var loc1;
            jsFun = arg1;
            if (!flash.external.ExternalInterface.available) 
            {
                return false;
            }
            try 
            {
                flash.external.ExternalInterface.call(jsFun);
            }
            catch (e)
            {
                return false;
            }
            return true;
        }

        public set title(arg1: string)
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return;
            }
            try 
            {
                flash.external.ExternalInterface.call("Brower.setTitle", arg1);
            }
            catch (e)
            {
            };
            return;
        }

        public get title(): string
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return null;
            }
            try 
            {
                return flash.external.ExternalInterface.call("Brower.getTitle");
            }
            catch (e)
            {
            };
            return "";
        }

        public set urlVariables(arg1: Object /* flash.net.URLVariables */)
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return;
            }
            var loc1="";
            var loc2=arg1.toString();
            if (loc2.length > 0) 
            {
                loc1 = loc1 + ("#" + loc2);
            }
            try 
            {
                flash.external.ExternalInterface.call("Brower.setUrlVariables", loc1);
            }
            catch (e)
            {
            };
            return;
        }

        public BrowerManager.get urlVariables(): Object /* flash.net.URLVariables */
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return null;
            }
            var loc1=this.url;
            var loc2=loc1.indexOf("#");
            if (loc2 > 0) 
            {
                return new Object /* flash.net.URLVariables */(loc1.substr(loc2 + 1));
            }
            return new Object /* flash.net.URLVariables */();
        }

        public addFavorite(arg1: string=null, arg2: string=null): void
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return;
            }
            if (!arg2) 
            {
                arg2 = this.url;
            }
            if (!arg1) 
            {
                arg1 = this.title;
            }
            try 
            {
                flash.external.ExternalInterface.call("Brower.addFavorite", arg2, arg1);
            }
            catch (e)
            {
            };
            return;
        }

        public setHomePage(arg1: string=null): void
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return;
            }
            if (!arg1) 
            {
                arg1 = this.url;
            }
            try 
            {
                flash.external.ExternalInterface.call("Brower.setHomePage", arg1);
            }
            catch (e)
            {
            };
            return;
        }

        public setCookie(name: string, value: string, date: Date=null, arg4: Boolean=false): void
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return;
            }
            if (!arg3) 
            {
                arg3;
                var loc1;
                arg3 = loc1 = new Date(new Date().time + 1000 * 86400 * 365);
            }
            arg3;
            try 
            {
                flash.external.ExternalInterface.call("Brower.setCookie", name, value, arg3.time, arg4);
            }
            catch (e)
            {
            };
            return;
        }

        public getCookie(name: string): string
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return null;
            }
            try 
            {
                return flash.external.ExternalInterface.call("Brower.getCookie", name);
            }
            catch (e)
            {
            };
            return "";
        }

        public confirmClose(arg1: string="确认退出？"): void
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return;
            }
            if (arg1) 
            {
                try 
                {
                    flash.external.ExternalInterface.call("Brower.confirmClose", arg1);
                }
                catch (e)
                {
                };
            }
            else 
            {
                try 
                {
                    flash.external.ExternalInterface.call("Brower.confirmClose");
                }
                catch (e)
                {
                };
            }
            return;
        }

        public alert(... rest): void
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return;
            }
            try 
            {
                flash.external.ExternalInterface.call("alert", rest.toString());
            }
            catch (e)
            {
            };
            return;
        }

        public reload(): void
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return;
            }
            try 
            {
                flash.external.ExternalInterface.call("location.reload");
            }
            catch (e)
            {
            };
            return;
        }

        public disableScroll(arg1: string=null): void
        {
            if (!flash.external.ExternalInterface.available) 
            {
                return;
            }
            try 
            {
                flash.external.ExternalInterface.call("Brower.disableScroll", arg1);
            }
            catch (e)
            {
            };
            return;
        }

        public getUrl(arg1: string, arg2: string="_self"): void
        {
            var loc1=null;
            if (arg1.substr(0, 11) == "javascript:" && flash.external.ExternalInterface.available) 
            {
                loc1 = arg1.substr(11);
                if (arg1.indexOf("(") == -1 && arg1.indexOf(")") == -1) 
                {
                    loc1 = loc1 + "()";
                }
                try 
                {
                    flash.external.ExternalInterface.call("eval", loc1);
                }
                catch (e)
                {
                };
            }
            else 
            {
                flash.net.navigateToURL(new Object /* flash.net.URLRequest */(arg1), arg2);
            }
            return;
        }

        public static get instance(): BrowerManager
        {
            if (BrowerManager._instance == null) 
            {
                BrowerManager._instance = new BrowerManager();
            }
            return BrowerManager._instance;
        }

        private static /* var */_instance: BrowerManager;
    }
